package com.margo.project.tomcat.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/elink")
public class MargoController {
	
	private Logger logger=LoggerFactory.getLogger(this.getClass());

	@ResponseBody
	@RequestMapping("/query/**")
	public String ss(HttpServletRequest request,
			HttpServletResponse response) {
		logger.info(request.getRequestURI().toString());
		return request.getContextPath();
	}
	
	@ResponseBody
	@RequestMapping("/go")
	public String go(HttpServletRequest request,
			HttpServletResponse response) {
		request.setAttribute("name", "margo");
		request.getSession().setAttribute("age", 28);
		logger.info(request.getRequestURI().toString());
		return request.getContextPath();
	}
	
	@ResponseBody
	@RequestMapping("/gotos")
	public String gotos(HttpServletRequest request,
			HttpServletResponse response) {
		logger.info("requestAttr:"+request.getAttribute("name"));
		logger.info("httpSessionAttr:"+request.getSession().getAttribute("age"));
		return "gotos";
	}
}
